<template>
	<view  >
	 
			<commonNavBar title="模板列表"  >  </commonNavBar>
	 
		<view class="centre">
			<view class="ul">
				<view class="li" v-for="(item, index) in documentTemplateList" :key="item.id" @click="documentTemplateOpen(item.id,item.templateName )">
					<view class="left"> 
						<image src="../../../static/img/documentTemplate.png" style="width: 23rpx;height: 32rpx;margin: 0 14rpx 0 30rpx;" mode=""></image>
						<view class="text">
							<view class="h1">{{ item.templateName }}</view>
						</view>
					</view>
					<view class="right">
						<view class="arrow"></view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import commonNavBar from '@/components/CommonNavBar.vue';
	 
	export default {
		components:{
			commonNavBar
		},
		data() {
			return {
				documentTemplateList: [],
				investigationId:null,
				type :null
			}
		},
		onLoad(options) {
			this.investigationId = options.investigationId
			this.type = options.type
			this.initData();
		}, 
		methods: {
			goBack() {
				console.log('goBack')
				uni.navigateBack();
			},
			async initData(){
				let res = await uni.$api.getDocTemplateList({
					 templateType : this.type
				});
				this.documentTemplateList = res.data.data;
			},
			documentTemplateOpen(id,title) { 
				const that = this;
				uni.navigateTo({
					url: '/pages/investigation/document/docTemplateInput?id='+id+"&title="+title + "&investigationId="+this.investigationId  + "&type="+this.type ,
					events:{
						updateImage(data){
							const eventChannel = that.getOpenerEventChannel();
							eventChannel.emit('updateDocument', data);
						}
					},
				})
			}
		} 
	}
</script>

<style  lang="scss">
	page {
		background: #F9F9F9;
	}
	 
	.centre {
		padding: 50rpx 17.5rpx 0 17.5rpx;
		height: calc(100vh - 165rpx);
		overflow-x: hidden;
		display: flex;
		flex-direction: column;
		
		.ul {
			
			.li {
				height: 98rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 100%);
				box-shadow: 0rpx 8rpx 15rpx 0rpx rgba(0,0,0,0.05);
				border-radius: 15rpx; 
				
				.left {
					display: flex;
					align-items: center;
					flex-direction: row;
					justify-content: flex-start;
					
					.text {
						
						.h1 {
							font-size: 23rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #333333;
							line-height: 31rpx;
							letter-spacing: 1px;
							padding-left: 15px;
							
						}
					}
				}
				
				.right {
					position: relative;
	
					.arrow {
						position: absolute;
						right: 50%;
						top: 50%;
						margin: 0 38rpx 0 0;
						width: 10rpx;
						height: 10rpx;
						border-left: 2rpx solid #888;
						border-top: 2rpx solid #888;
						transform: translate(-50%, -50%) rotate(135deg);
					}
				}
				
				&+.li {
					margin: 12.5rpx auto 0;
				}
			}
		}
	}
</style>